{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "data_path = 'raw-data/'\n",
    "output_path = 'data/WUSTL-IIoT'\n",
    "df = pd.read_csv(data_path + 'wustl_iiot_2021.csv', low_memory=False)\n",
    "df = df.sort_values(by=['StartTime'])\n",
    "mask = list(df['Target'])\n",
    "quarter_mask = len(mask)//4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "recon_df = df[:quarter_mask+10000]\n",
    "recon_df['Traffic'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dos_df = df[quarter_mask+10000:2*quarter_mask]\n",
    "dos_df['Traffic'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "comm_df = df[2*quarter_mask:3*quarter_mask]\n",
    "comm_df['Traffic'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_df = df[3*quarter_mask:]\n",
    "train_df['Traffic'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_df.to_pickle(output_path+'train_WUSTL-IIoT.pkl')\n",
    "recon_df.to_pickle(output_path+'recon_WUSTL-IIoT.pkl')\n",
    "dos_df.to_pickle(output_path+'dos_WUSTL-IIoT.pkl')\n",
    "comm_df.to_pickle(output_path+'comm_WUSTL-IIoT.pkl')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "11938c6bc6919ae2720b4d5011047913343b08a43b18698fd82dedb0d4417594"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
